<?php
namespace app\api\controller\service;

use app\common\controller\Api;

/**
 * 首页接口
 */
class Notice extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 平台公告
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getList()
    {
        $type = input('type/d',0);
        $page = input('page/d',1);
        $limit = 10;
        $list = model('app\api\model\service\Notice')->where(['type'=>$type,'state'=>1])->field('id,title,image,createtime')->order('weigh desc,id desc')->page($page)->limit($limit)->select();
        $this->success('列表返回成功',$list);
    }


    public function detail()
    {
        $id = input('id/d','');
        $info = model('app\api\model\service\Notice')->where(['id'=>$id,'state'=>1])->find();
        !$info && $this->error('信息异常');
        $info['content'] = htmlspecialchars_decode($info['content']);
        $this->success('信息返回成功',$info);
    }


}
